//package com.jt.config;
//
//import lombok.extern.slf4j.Slf4j;
//import org.mapstruct.Qualifier;
//import org.springframework.amqp.core.*;
//import org.springframework.amqp.rabbit.annotation.Exchange;
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.connection.CorrelationData;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//
//@Configuration
//@Slf4j
//public class RabbitmqConfig {
//    @Autowired
//    private CachingConnectionFactory connectionFactory;
//
//    @Bean(name = "queue")
//    public Queue deviceTreatedQueue(){
//        return new Queue("testQueue333",true);
//    }
//
//    @Bean
//    public Exchange deviceTreatedExchange(){
//        return ExchangeBuilder.topicExchange("testExchange333").durable(true).build();
//    }
//
//    @Bean
//    public Binding deviceTreatedBinding(){
//        return BindingBuilder.bind(deviceTreatedQueue()).to((FanoutExchange) deviceTreatedExchange());
//    }
//
//    @Bean
//    public RabbitTemplate rabbitTemplate(){
//        connectionFactory.setPublisherConfirms(true);
//        connectionFactory.setPublisherReturns(true);
//        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
//        rabbitTemplate.setMandatory(true);
//        rabbitTemplate.setConfirmCallback(new RabbitTemplate.ConfirmCallback() {
//            @Override
//            public void confirm(CorrelationData correlationData, boolean ack, String cause) {
//                log.info("消息发送成功:correlationData({}),ack({}),cause({})",correlationData,ack,cause);
//            }
//        });
//        rabbitTemplate.setReturnCallback(new RabbitTemplate.ReturnCallback() {
//            @Override
//            public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
//                log.info("消息丢失:exchange({}),route({}),replyCode({}),replyText({}),message:{}",exchange,routingKey,replyCode,replyText,message);
//            }
//        });
//        return rabbitTemplate;
//    }
//
//
//}
